﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LiveSequence.Interface;
using LiveSequence.Suite.Patterns;
using LiveSequence.Suite.Domain;

namespace LiveSequence.Suite.Documents
{
  public class DocManager : Singleton<DocManager>
  {
    private IDocument _activeDocument;
    private ProjectDoc _masterDocument;

    public event EventHandler ActiveDocumentChanged;
    public event EventHandler MasterDocumentChanged;
    
		public DocManager()
		{
			string strFileName = string.Format("Project");
			ProjectDoc projectDoc = new ProjectDoc(new LSProject());
			MasterDocument = projectDoc;
			
		}

    public IDocument ActiveDocument
    {
      get { return _activeDocument; }
      set
      {
        _activeDocument = value;
        OnActiveDocumentChanged();
      }
    }

    private void OnActiveDocumentChanged()
    {      
      if(ActiveDocumentChanged!=null)
      {
        ActiveDocumentChanged(null, EventArgs.Empty);
      }
    }

    public ProjectDoc MasterDocument
    {
      get { return _masterDocument; }
      set
      {
        _masterDocument = value;
        OnMasterDocumentChanged();
      }
    }

    private void OnMasterDocumentChanged()
    {
      if (MasterDocumentChanged != null)
      {
        MasterDocumentChanged(null, EventArgs.Empty);
      }

    }

    

  }
}
